package com.kuun.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.kuun.domain.Order;
import com.kuun.service.impl.OrderServiceImpl;

@RestController
@RequestMapping("mongo")
public class OrderController {
	@Autowired
	private OrderServiceImpl orderService ;
	
	@RequestMapping(value="/submitOrder",method=RequestMethod.POST)
	public String submitOrder(@RequestParam("customerName")String customerName,@RequestParam("restaurantName")String restaurantName){
		orderService.submitOrder(customerName,restaurantName);
		return "submitOrder success..." ;
	}
	
	@RequestMapping("/findOrderByOrderId")
	public Order findOrderByOrderId(@RequestParam("orderId")Integer orderId){
		return orderService.findOrderByOrderId(orderId) ;
	}
	
	@RequestMapping("/getOrderByCustomerName")
	public List<Order> getOrderByCustomerName(@RequestParam("customerName")String customerName){
		return orderService.getOrderByCustomerName(customerName) ;
	}
	
	
	@RequestMapping("/deleteOrderByOrderId")
	public String deleteOrderByOrderId(@RequestParam("orderId")String orderId){
		if(orderService.deleteOrderByOrderId(orderId)){
			return "deleteOrderByOrderId success..." ;
		}else{
			return "default..." ;
		}
	}
	
	
}
